<template>
	<Layout class="p-5 bg-white">
		<h1 style="text-align: center;margin: 20px;">买房信息修改</h1>
		<Form :label-width="150" style="margin-left: 650px;">
			
			<FormItem class="w-50" label="房子标题">
				<Input v-model="houseRentClientVo.house.title" style="width:300px" placeholder="请输入房子标题"></Input>
			</FormItem>
			<FormItem class="w-50" label="电话号">
				<Input v-model="houseRentClientVo.house.tel" style="width:300px" placeholder="请输入电话号"></Input>
			</FormItem>
			<FormItem class="w-50" label="微信号">
				<Input v-model="houseRentClientVo.house.wxNumber" style="width:300px" placeholder="请输入微信号"></Input>(非必填)
			</FormItem>
			<FormItem class="w-50" label="房子详情">
				<Input v-model="houseRentClientVo.house.detail" type="textarea" style="width:300px" placeholder="请输入房子详情"></Input>
			</FormItem>
			<FormItem class="text-right">
				<Button @click="submit" type="primary">提交</Button>
				<Button @click="cancel" class="ml-2">取消</Button>
			</FormItem>
		</Form>
	</Layout>
</template>

<script>
	export default {
		data() {
			return {
				houseRentClientVo: {
					url:'',
					modal11: false,
					currentUser:{},
					house:{
						houseBuyId:'',
						title: "",
						tel:'',
						wxNumber:"",
						detail: "",
						clientId : ''
					}
					
				},
			}
		},
		created: function() {
			this.$data.houseRentClientVo.currentUser = JSON.parse(sessionStorage.getItem('CURRENT'))
			this.$data.houseRentClientVo.house.clientId = this.$data.houseRentClientVo.currentUser.client.clientId
			this.$data.houseRentClientVo.house.houseBuyId = this.$route.params.houseBuyId
			this.getHouseList()
			
		},
		beforeRouteLeave(to, from, next) {
		    this.$destroy();//手动销毁当前页面
		    next();
		},
		methods: {
			getHouseList:function(){
				this.http.get({
					url:'/house-buy-client-vo/info',
					param:{ houseBuyId:this.$data.houseRentClientVo.house.houseBuyId }
				}).then((data) => {
					this.$data.houseRentClientVo.house = data
					console.log(data)
				})
			},
			submit: function() {
        if(this.$data.houseRentClientVo.tel === ""){
          this.message.error("电话必须输入");
          return;
        }
				let self = this;
				this.http.put({
					url: "/house-buy-client-vo/info",
					param: {
						houseBuyId:this.$data.houseRentClientVo.house.houseBuyId,
						title: this.$data.houseRentClientVo.house.title,
						detail: this.$data.houseRentClientVo.house.detail,
						tel: this.$data.houseRentClientVo.house.tel,
						wxNumber:this.$data.houseRentClientVo.house.wxNumber,
						clientId: this.$data.houseRentClientVo.house.clientId,
					}
				}).then(data => {
					self.message.info("修改成功");
					this.cancel()
				});
			},
			cancel: function() {
				this.$router.push({
					name:'user_center_fang_buy'
				})
			},
		}
	}
</script>

<style>
</style>
